package com.haoshuang.zhouzhoubang.ui.page.order.take.services

import com.haoshuang.zhouzhoubang.databinding.ItemChooseServiceRightCateBinding
import com.haoshuang.zhouzhoubang.model.bean.ChooseServiceBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.core.setOnItemClick
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.view.vertical


/**
 *
 */
class ChooseServiceRightCateAdapter(data: MutableList<ChooseServiceBean.SecondCate>) :
    BaseBindingQuickAdapter<ChooseServiceBean.SecondCate, ItemChooseServiceRightCateBinding>(data) {

    override fun onBindViewHolder(
        holder: BaseBindingHolder,
        position: Int,
        item: ChooseServiceBean.SecondCate?
    ) {
        holder.getViewBinding<ItemChooseServiceRightCateBinding>().apply {

            val adapter = ChooseServicesAdapter(item?.list?: mutableListOf())
            recyclerView.vertical(3).adapter = adapter

            tvCateName.text = item?.cate_name

            adapter.setOnItemClick { view, position, item ->
                if (context is ChooseServicesActivity) {
                    (context as ChooseServicesActivity).onServiceItemClick(item)
                }
            }

        }
    }

}